package gov.ccswj.modules.apibusiness.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import gov.ccswj.modules.api.annotation.AuthIgnore;
import gov.ccswj.modules.apibusiness.service.DevelopmentPromotionService;
import gov.ccswj.modules.apibusiness.utils.ApiR;

/**
 * @author KY.Cheng
 * 3.2外贸中小企业发展促进系统-接口
 */
@RestController
@RequestMapping("/api/developmentpromotion")
public class DevelopmentPromotionController {

	@Autowired
	private DevelopmentPromotionService developmentPromotionService;

	/**
	 *	2.1 贸易资讯 列表
	 */
	@AuthIgnore
	@GetMapping("/tradelist")
	public ApiR tradelist(HttpServletResponse response,Integer s,Integer n) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		if (s==null||n==null) {
			return ApiR.ok().put("status", "108").put("message", "s，n参数有误");
		}
		List<Map<String, Object>> list = developmentPromotionService.queryTradeInfoList(s, n);
		
		return ApiR.ok().put("total", list.size()).put("data", list);
	}
	/**
	 *	2.1 贸易资讯 详情
	 */
	@AuthIgnore
	@GetMapping("/tradeinfo")
	public ApiR tradeinfo(HttpServletResponse response,String id) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		if (StringUtils.isBlank(id)) {
			return ApiR.ok().put("status", "108").put("message", "id不能为空");
		}
		Map<String, Object> obj = developmentPromotionService.queryTradeInfo(id);
		
		return ApiR.ok().put("data", obj);
	}
	
	/**
	 *	2.2 风险预警 列表
	 */
	@AuthIgnore
	@GetMapping("/warninginfolist")
	public ApiR warninginfolist(HttpServletResponse response,Integer s,Integer n) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		if (s==null||n==null) {
			return ApiR.ok().put("status", "108").put("message", "s，n参数有误");
		}
		List<Map<String, Object>> list = developmentPromotionService.queryWarningInfoList(s, n);
		
		return ApiR.ok().put("total", list.size()).put("data", list);
	}
	/**
	 *	2.2 风险预警 详情
	 */
	@AuthIgnore
	@GetMapping("/warninginfo")
	public ApiR warninginfo(HttpServletResponse response,String id) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		if (StringUtils.isBlank(id)) {
			return ApiR.ok().put("status", "108").put("message", "id不能为空");
		}
		Map<String, Object> obj = developmentPromotionService.queryWarningInfo(id);
		
		return ApiR.ok().put("data", obj);
	}
	
	/**
	 *	2.4融资对接 列表
	 */
	@AuthIgnore
	@GetMapping("/financingdockinglist")
	public ApiR financingdockinglist(HttpServletResponse response,Integer s,Integer n) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		if (s==null||n==null) {
			return ApiR.ok().put("status", "108").put("message", "s，n参数有误");
		}
		List<Map<String, Object>> list = developmentPromotionService.queryFinancingDockingList(s, n);
		
		return ApiR.ok().put("total", list.size()).put("data", list);
	}
	/**
	 *	2.4融资对接 详情
	 */
	@AuthIgnore
	@GetMapping("/financingdocking")
	public ApiR financingdocking(HttpServletResponse response,String id) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		if (StringUtils.isBlank(id)) {
			return ApiR.ok().put("status", "108").put("message", "id不能为空");
		}
		Map<String, Object> obj = developmentPromotionService.queryFinancingDocking(id);
		
		return ApiR.ok().put("data", obj);
	}
	
	/**
	 *	2.5 展会信息 列表
	 */
	@AuthIgnore
	@GetMapping("/exhibitionlist")
	public ApiR exhibitionlist(HttpServletResponse response,Integer s,Integer n,String type) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		if (s==null||n==null) {
			return ApiR.ok().put("status", "108").put("message", "s，n参数有误");
		}
		List<Map<String, Object>> list = developmentPromotionService.queryExhibitionList(s, n, type);
		
		return ApiR.ok().put("total", list.size()).put("data", list);
	}
	/**
	 *	2.5 展会信息 详情
	 */
	@AuthIgnore
	@GetMapping("/exhibition")
	public ApiR exhibition(HttpServletResponse response,String id) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		if (StringUtils.isBlank(id)) {
			return ApiR.ok().put("status", "108").put("message", "id不能为空");
		}
		Map<String, Object> obj = developmentPromotionService.queryExhibition(id);
		
		return ApiR.ok().put("data", obj);
	}
	
	/**
	 *	2.6.1单证贸易知识 列表
	 */
	@AuthIgnore
	@GetMapping("/knowledgetradelist")
	public ApiR knowledgetradelist(HttpServletResponse response,Integer s,Integer n,String type,
			String countries,String document,String fomat,String text) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		if (s==null||n==null) {
			return ApiR.ok().put("status", "108").put("message", "s，n参数有误");
		}
		List<Map<String, Object>> list = developmentPromotionService.queryKnowledgeTradeList(s, n, type, countries, document, fomat, text);
		
		return ApiR.ok().put("total", list.size()).put("data", list);
	}
	/**
	 *	2.6.1单证贸易知识 详情
	 */
	@AuthIgnore
	@GetMapping("/knowledgetrade")
	public ApiR knowledgetrade(HttpServletResponse response,String id) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		if (StringUtils.isBlank(id)) {
			return ApiR.ok().put("status", "108").put("message", "id不能为空");
		}
		Map<String, Object> obj = developmentPromotionService.queryKnowledgeTrade(id);
		
		return ApiR.ok().put("data", obj);
	}
	
	/**
	 *	2.6.2贸易税费 列表
	 */
	@AuthIgnore
	@GetMapping("/knowledgetaxratelist")
	public ApiR knowledgetaxratelist(HttpServletResponse response,Integer s,Integer n,String code,String importingCountry,String exportingCountry) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		if (s==null||n==null) {
			return ApiR.ok().put("status", "108").put("message", "s，n参数有误");
		}
		List<Map<String, Object>> list = developmentPromotionService.queryKnowledgeTaxrateList(s, n, code, importingCountry, exportingCountry);
		
		return ApiR.ok().put("total", list.size()).put("data", list);
	}
	/**
	 *	2.6.2贸易税费 详情
	 */
	@AuthIgnore
	@GetMapping("/knowledgetaxrate")
	public ApiR knowledgetaxrate(HttpServletResponse response,String id) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		if (StringUtils.isBlank(id)) {
			return ApiR.ok().put("status", "108").put("message", "id不能为空");
		}
		Map<String, Object> obj = developmentPromotionService.queryKnowledgeTaxrate(id);
		
		return ApiR.ok().put("data", obj);
	}

	
	/**
	 *	2.6.3出口商品技术指南 列表
	 */
	@AuthIgnore
	@GetMapping("/knowledgeguidelist")
	public ApiR knowledgeguidelist(HttpServletResponse response,Integer s,Integer n,String text) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		if (s==null||n==null) {
			return ApiR.ok().put("status", "108").put("message", "s，n参数有误");
		}
		List<Map<String, Object>> list = developmentPromotionService.queryKnowledgeGuideList(s, n, text);
		
		return ApiR.ok().put("total", list.size()).put("data", list);
	}
	/**
	 *	2.6.3出口商品技术指南 详情
	 */
	@AuthIgnore
	@GetMapping("/knowledgeguide")
	public ApiR knowledgeguide(HttpServletResponse response,String id) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		if (StringUtils.isBlank(id)) {
			return ApiR.ok().put("status", "108").put("message", "id不能为空");
		}
		Map<String, Object> obj = developmentPromotionService.queryKnowledgeGuide(id);
		
		return ApiR.ok().put("data", obj);
	}
}
